package com.example.xiaomi.service;

import com.example.xiaomi.entity.contents;
import com.example.xiaomi.mapper.ContentsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import java.util.List;
@Service
public class ContentsServiceImpl implements ContentsService{
    @Autowired
    private ContentsMapper mapper;
    @Override
    public List<contents> findAllContents(){
        List<contents> allContents = mapper.findAllContents();
        return allContents;
    }

    @Override
    public List<contents> findContentsAccount(){
        List<contents> numberContents=mapper.findContentsAccount();
        return numberContents;
    }
    @Override
    public List<contents> findContentsById(Integer mid){
        return mapper.findContentsById(mid);
    }
    @Override
    public PageInfo<contents> findContentsPages(Integer pageNum, Integer pageSize, String contents) {
        PageHelper.startPage(pageNum, pageSize);
        List<contents> lists = mapper.findAllContents();
        PageInfo<contents> pageInfo = new PageInfo<>(lists);
        return pageInfo;
    }
    @Override
    public List<contents> findContentsByContents(String contents) {
        return mapper.findContentsByContents(contents);
    }
    @Override
    public List<contents> findContentsByDate(){return mapper.findContentsByDate();}
    @Override
    public List<contents> findContentsTopic(Integer stage_idx,Integer topic_idx ){
        List<contents> info=mapper.findContentsTopic(stage_idx, topic_idx);
        return info;
    }
    @Override
    public List<contents> findContentsTopic1(){
        List<contents> info=mapper.findContentsTopic1();
        return info;
    }
}
